package optim;

public class Timer {
	private long startTime = 0;
	private long stopTime = 0;

	public void start() {
		startTime = System.currentTimeMillis();
		stopTime = 0;
	}

	public void stop() {
		stopTime = System.currentTimeMillis();
	}

	public long getTime() {
		long currTime = stopTime;
		if (stopTime == 0) // still running
			currTime = System.currentTimeMillis();

		return currTime - startTime;
	}

	public double getTimeSecs() {
		long currTime = stopTime;
		if (stopTime == 0) // still running
			currTime = System.currentTimeMillis();

		return (currTime - startTime) / 1000.0;
	}
}
